FilesController = $.Controller.extend('files', {
	mouseover : function(params){
		var el = params.element;
		if(el.id != MainController.old_selected_id())
			el.style.backgroundColor = '#E8EEF7';
	},
	mouseout : function(params){
		var el = params.element;
		if(el.id != MainController.old_selected_id())
			el.style.backgroundColor = '';
	},
	dblclick : function(params){
		IDE.clear_selection();
		var el = params.element;
		MainController.set_selected(el);
		this.element = el;
		this.title = el.innerHTML;
		el.innerHTML = 'Opening ...';
		new MVC.Ajax('/ftp/open?path='+encodeURIComponent( el.id ), 
			{method: 'POST', onComplete: this.continue_to('opened') } );	
	},
	opened : function(response){
		this.element.innerHTML = this.title;
	   	var id= this.element.id;
		var f= new MVC.JFile(id);
		var new_file= {id: id, text: response.responseText, syntax: f.extension().toLowerCase(), title: f.file_and_extension() };
		editAreaLoader.openFile('EDITAREA_TEXTAREA', new_file);
	},
	contextmenu : function(params){
		MainController.set_selected(params.element);
		var menu = JITS.rightClickMenu.open( this.render() , params.event);
		params.event.kill();
	},
	click : function(params){
		MainController.set_selected(params.element);
	},
    dragstart : function(params){
        params.cache_position();
        params.revert();
    }
});

